package com.dream.root.user.controller;

import com.dream.root.common.annotation.HttpApi;
import com.dream.root.common.response.BaseResponse;
import com.dream.root.user.config.cache.RedisKeys;
import com.dream.root.user.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TestController Created with IntelliJ IDEA.
 * User: liulinhui
 * Date: 28/07/2018
 * Time: 03:21
 * Description: TestController
 */
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Resource
    private UserInfoService userInfoService;

    @GetMapping("index")
    @Cacheable(value = RedisKeys.tenSec)
    @HttpApi
    public BaseResponse test(@RequestParam("userId") Integer userId) {
        log.info("parameter is:" + userId);
        return new BaseResponse(userInfoService.selectById(userId));
    }
}
